package com.zhl.scheduling.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author: ZhangLu In DLUT
 * @since: 1.0.0
 * @Description: 将Swagger交给SpringBoot管理的配置类
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /* swagger会帮助我们⽣成接⼝⽂档
     * 1：配置⽣成的⽂档信息
     * 2: 配置⽣成规则*/

    /*Docket封装接⼝⽂档信息*/

    @Bean
    public Docket getDocket(){
        //创建封⾯信息对象
        ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder();
        apiInfoBuilder.title("《生产调度系统》后端接⼝说明")
                .description("此⽂档详细说明了生产调度系统项⽬后端接⼝规范")
                .version("v 1.0.0")
                .contact( new Contact("张露","https://space.bilibili.com/404975444?spm_id_from=333.1007.0.0","zhangluujs@163.com") );
        ApiInfo apiInfo =  apiInfoBuilder.build();

        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                //指定⽣成的⽂档中的封⾯信息：⽂档标题、版本、作者
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zhl.scheduling.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}
